<meta charset="UTF-8">
<?php

include_once("../functions/db_manipulate.php");
if (!init()) {
    redirect('login.php');
}

connectDB();
startTransaction();

$resultSet = mysql_query("DELETE FROM usrgroup WHERE userid='" . mysql_real_escape_string($_SESSION['id']) . "' AND groupid='" . mysql_real_escape_string($_GET['gid']) . "'") or die(mysql_error());

if ($resultSet) {
    commitTransaction();
    header($_SERVER['HTTP_REFERER']);
} else {
    rollbackTransaction();
    echo mysql_error();
}
?>